package com.wxtf.platform.main.sygl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.*;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import com.wxtf.platform.tools.FormatUtil;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.CellStyle;

import com.wxtf.platform.interfaces.CommonsCallProvider;
import com.wxtf.platform.plugins.user.UserBean;
import com.wxtf.platform.supers.LogicBase;
import com.wxtf.platform.tools.Common;
import com.wxtf.platform.tools.ConstantInfoHelper;
import com.wxtf.platform.tools.AccessDataBaseUtil;
import com.wxtf.platform.tools.XLSUtils;

/**
 * <li>Title: sygl_tognjiAction.java</li>
 * <li>Project: baseplatform</li>
 * <li>Package: com.wxtf.platform.main.sygl</li>
 * <li>Description: 生育情况统计表</li>
 * <li>Copyright: Copyright (c) 2012</li>
 * <li>Company: wxthtf Technologies </li>
 * <li>Created on Aug 21, 2012 10:29:02 AM</li>
 * 
 * @author wangli
 * @version 1.0.0.0
 * 
 */
public class sygl_tognjiAction extends LogicBase implements CommonsCallProvider{
	private static final Log log = LogFactory.getLog(sygl_tognjiAction.class);

	public sygl_tognjiAction(String jsonArray) {

	}

	@Override
	public Object run() {
		Object msg = "";
		UserBean user = (UserBean)this.getRequest().getSession().getAttribute("userBean");
		try {
			if("queryPage".equals(this.getMethodName())) {
				msg = this.select(this.getLogicData());
				return msg;
			} else if("download".equals(this.getMethodName())) {
				msg = this.download(this.getLogicData());
			} else if("search".equals(this.getMethodName())) {
				msg = this.search1(this.getLogicData());
			} else if("queryDetail".equals(this.getMethodName())) {
				msg = this.queryDetail(this.getLogicData());
			} else if("expData".equals(this.getMethodName())) {
				msg = this.expData(this.getLogicData());
			} else {
				msg = "\"没有【" + this.getMethodName() + "】该方法\"";
			}

			if(msg == null || "[null]".equals(msg)) {
				msg = "\"\"";
			}
			if(msg.toString().startsWith("{") || msg.toString().startsWith("[")) {
				return msg;
			}
			msg = ConstantInfoHelper.generateJSONString(msg.toString());
		} catch (Exception e) {
			msg = ConstantInfoHelper.generateErrorJSONString();
			log.error(user.getUserrelName(), e);
		} finally {
			this.clear();
		}
		return msg.toString();
	}

	@Override
	public Object select(Object jsonArray) throws Exception {
		UserBean user = (UserBean) this.getRequest().getSession().getAttribute("userBean");
		JSONArray array = JSONArray.fromObject(jsonArray);
		StringBuffer sb = new StringBuffer();
		StringBuffer sbs = new StringBuffer();
		StringBuffer sb_1 = new StringBuffer();
		
		if(array.size() > 0) {
			JSONObject jsonObject = JSONObject.fromObject(array.getString(0));
			String types = jsonObject.getString("types");
			String[] subOrg;
			String strOrg="";
			//System.out.println("types---"+types);
			if("init".equals(types)) {// 初始查询
				subOrg = user.getCurSubOrgId().split(",");
				strOrg = user.getCurSubOrgId();//获取当前机构及以下的总数
			} else if("serch1".equals(types)) {// 条件查询
				String orgIds = jsonObject.getString("orgIds");//机构ID串
				if(StringUtils.isNotBlank(orgIds)){
					subOrg = user.getCurSubOrgIds(orgIds).split(",");
				}else{
					subOrg = user.getCurSubOrgId().split(",");}
				strOrg = user.getCurSubOrgIds(orgIds);//获取当前某一机构及以下的总数
			}else{ subOrg = new String[0];  }
			if(subOrg.length>0)
				{
					int len=0;
					for(int m=0;m<subOrg.length;m++)
					{
						//查询当前组织机构的名称
						//System.out.println("组织机构："+subOrg[m]);
						String empSql = "select CAPTION from t_department where DEPARTMENT_ID ="+subOrg[m]+"";
						List<Object> lemp = AccessDataBaseUtil.query4List(empSql,null);
						if(lemp.size()>0)
						{
							StringBuffer buff = new StringBuffer();
							//查出已婚育龄夫妻双方，生育情况人数
							buff.append(" FROM(SELECT e.org_id,p.tbepr_option as id,n.tbenm_plan_status as status1,f.tbfi_id as tbe_name,n.tbenm_gravida_num as status2,n.reserve4 as types")
									.append(" from tbe_pregnancy_record p LEFT JOIN tbe_neonate_main n ON p.tbepr_id=n.tbepr_id")
									.append(" LEFT JOIN tb_family_base f ON p.tbfi_id=f.tbfi_id LEFT JOIN tb_employee e ON f.tbe_id=e.tbe_id where e.tbe_status not in('102-5','102-4','102-3') and (n.reserve5 is NULL or n.reserve5 <> '1')")
									.append(" UNION ")
							//已婚育龄男1.无妻子：离异，丧偶 2.有妻子：妻子年龄20-49
									.append(" SELECT e.org_id,e.tbe_id as id,e.tbe_sex as status1,tbe_name,'total' as status2,'birth' as types FROM tb_employee e LEFT JOIN tb_family_base f ON e.tbe_id=f.tbe_id where ")
									.append("(tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or f.tbfi_spouse_birthday is null")
									.append(" or (f.tbfi_spouse_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and f.tbfi_spouse_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR)))")
									.append(" and tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
									.append(" and e.tbe_employment_forms <> '31' and e.tbe_sex='男' ")
									.append(" UNION ")
								//已婚育龄女//年龄20-49
									.append(" SELECT org_id,tbe_id as id,tbe_sex as status1,tbe_name,'total' as status2,'birth' as types FROM tb_employee where ")
									.append(" tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
									.append(" and tbe_employment_forms <> '31' and tbe_sex='女' and tbe_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and tbe_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR)")
									.append(" UNION ")
								//已婚育龄无生育男【离异，丧偶，不孕症】妻子年龄20-49
									.append(" SELECT e.org_id,e.tbe_id as id,e.tbe_sex as status1,tbe_name,'no' as status2,'birth' as types FROM tb_employee e LEFT JOIN tb_family_base f ON e.tbe_id=f.tbe_id where")
									.append(" (tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or (((f.tbfi_spouse_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and f.tbfi_spouse_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR)) or f.tbfi_spouse_birthday is null) and tbe_is_barrenness='1'))")
									.append(" and tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
									.append(" and e.tbe_employment_forms <> '31' and e.tbe_sex='男' ")
								//已婚育龄无生育女
									.append(" UNION ")
									.append(" SELECT org_id,tbe_id as id,tbe_sex as status1,tbe_name,'no' as status2,'birth' as types FROM tb_employee where tbe_id not in (SELECT tbe_id from tb_employee where tbe_is_barrenness='0' and the_is_menopause='0'")
									.append(" and tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617')) and tbe_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and tbe_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR) ")
									.append(" and tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
									.append(" and tbe_employment_forms <> '31' and tbe_sex='女' ")
							//死亡，已离职，已退休状态,未婚状态的除外
									.append(" UNION ")
							//办证[劳务用工和已离职和已退休的员工不能添加]
									.append("SELECT e.org_id,o.tbeocr_id as id,e.tbe_id as status1,f.tbe_spouse_id as tbe_name,o.reserve2 as status2,'credent' as types")
									.append(" from tb_family_base f LEFT JOIN tb_employee e on f.tbe_id=e.tbe_id LEFT JOIN tbe_only_child_record o on f.tbfi_id=o.tbfi_id where e.tbe_employment_forms <> '31' and f.tbfi_children_num = 1 and tbe_status not in('102-4','102-3') and e.tbe_sex='男'")
									.append(" UNION ")
									.append("SELECT e.org_id,o.tbeocr_id as id,f.tbe_spouse_id as status1,e.tbe_id as tbe_name,o.reserve2 as status2,'credent' as types")
									.append(" from tb_family_base f LEFT JOIN tb_employee e on f.tbe_id=e.tbe_id LEFT JOIN tbe_only_child_record o on f.tbfi_id=o.tbfi_id where e.tbe_employment_forms <> '31' and f.tbfi_children_num = 1 and tbe_status not in('102-4','102-3') and e.tbe_sex='女')t where 1 = 1 ");
							len++;
							String name = lemp.get(0).toString();

							if(m>0)
							{
								buff.append(" and org_id in (" + subOrg[m] + ") ");//单个分支机构
							}
							else
							{
								buff.append(" and org_id in (" + strOrg + ") ");//汇总机构
							}
							
							String querySql = "SELECT org_id,id,status1,tbe_name,status2,types" + buff.toString();
							String[] fields = {"org_id", "id","status1","tbe_name","status2", "types"};
							List<Map<String, String>> list = AccessDataBaseUtil.query(fields, querySql,null);
							
							int pregnancying = 0;//等孕
							int pregnancyed = 0;//怀孕
							int plan = 0;//婴儿数
							int plan1 = 0;//计划一
							int plan2 = 0;//计划二
							int late = 0;//晚婚+晚育
							
							//生育
							int pregnancy=0;//已婚育龄总职工数
							int pregnancym=0;//已婚育龄男
							int pregnancyf=0;//已婚育龄女
							int nobirthp=0;//无生育职工
							int nobirthm=0;//无生育男
							int nobirthf=0;//无生育女
							
							//办证情况
							int	child= 0;//子女数
							int emp = 0;//应办证
							int credentied = 0;//已办证
							int credentials=0;//未办证
							List<Map<String, String>> listchild = new ArrayList<Map<String, String>>();
							if (list.size() > 0) {
								//pregnancy = list.size();
								for (int i = 0; i < list.size(); i++) {// 行
									Map<String, String> map = list.get(i);
									if(map.get("types").equals("credent"))//办证
									{
										Map<String, String> mapfm = new HashMap<String, String>();
										mapfm.put(map.get("status1"),map.get("tbe_name"));
										//子女数
										if(!listchild.contains(mapfm))
										{
											listchild.add(mapfm);
										}
										
										//已办证
										if (!map.get("id").equals("")) {
											if(map.get("status2").equals(""))
											{
												credentied += 1;
											}
											
										}
										emp++;
									}
									else if(map.get("types").equals("birth"))
									{
										if(map.get("status2").equals("no"))
										{
											if(map.get("status1").equals("男"))
											{
												nobirthm += 1;
											}else{nobirthf += 1;}
										}else{
											if(map.get("status1").equals("男"))
											{
												pregnancym += 1;
											}else{pregnancyf += 1;}
										}
									}else{
										if (map.get("id").equals("0")) {
											pregnancyed += 1;//怀孕
										}
										if (map.get("id").equals("1")) {
											pregnancying += 1;//等孕
										}
										if (map.get("status1").equals("0")) {//计划内一胎
											String num = map.get("status2");// 胎数
											num = num.equals("") ? "0" : num;
											plan1 += Integer.parseInt(num);
											plan += Integer.parseInt(num);
											
											if (map.get("types").equals("1")) {//晚婚+晚育
												late += Integer.parseInt(num);
											}
										}
										if (map.get("status1").equals("1")) {//计划内二胎
											String num = map.get("status2");// 胎数
											num = num.equals("") ? "0" : num;
											plan2 += Integer.parseInt(num);
											plan += Integer.parseInt(num);
										}
									}
								}
							}
							child = listchild.size();
							credentials = emp - credentied;
							
							nobirthp = nobirthm + nobirthf;
							pregnancy = pregnancym + pregnancyf;
							int havebirth = (pregnancy > nobirthp) ? pregnancy-nobirthp : 0;//有生育职工
							int havebirthm=(pregnancym > nobirthm) ? pregnancym-nobirthm : 0;//有生育男
							int havebirthf=(pregnancyf > nobirthf) ? pregnancyf-nobirthf : 0;//有生育女
							
							if(m>0)
							{
								sbs.append("{ \"name1\": \""+name+"\", \"orgid\": \""+subOrg[m]+"\",\"name2\": \""+pregnancy+"\", \"name3\": \""+pregnancym+"\", \"name4\": \""+pregnancyf+"\", \"name5\": \""+nobirthp+"\", \"name6\": \""+nobirthm+"\", \"name7\": \""+nobirthf+"\", \"name8\": \""+havebirth+"\", \"name9\": \""+havebirthm+"\", \"name10\": \""+havebirthf+"\", \"name11\": \""+emp+"\", \"name12\": \""+credentied+"\", \"name13\": \""+credentials+"\", \"name14\": \""+child+"\", \"name15\": \""+pregnancyed+"\", \"name16\": \""+pregnancying+"\", \"name17\": \""+plan+"\", \"name18\": \""+plan1+"\", \"name19\": \""+plan2+"\", \"name20\": \""+late+"\"},");
							}
							else
							{
								sb.append("{\"Total\":\"1\",\"Rows\":[");
								sb.append("{ \"name1\": \""+name+"\",\"orgid\": \""+subOrg[m]+"\", \"name2\": \""+pregnancy+"\", \"name3\": \""+pregnancym+"\", \"name4\": \""+pregnancyf+"\", \"name5\": \""+nobirthp+"\", \"name6\": \""+nobirthm+"\", \"name7\": \""+nobirthf+"\", \"name8\": \""+havebirth+"\", \"name9\": \""+havebirthm+"\", \"name10\": \""+havebirthf+"\", \"name11\": \""+emp+"\", \"name12\": \""+credentied+"\", \"name13\": \""+credentials+"\", \"name14\": \""+child+"\", \"name15\": \""+pregnancyed+"\", \"name16\": \""+pregnancying+"\", \"name17\": \""+plan+"\", \"name18\": \""+plan1+"\", \"name19\": \""+plan2+"\", \"name20\": \""+late+"\",");
							}
						}
					}
					len = (len>0) ? len-1 : len;
					
					if(!sbs.equals("")&&sbs.length()>0)
					{
						String sb1 = "{\"Total\":\""+len+"\",\"Rows\":[";
						String sb2 = sbs.substring(0, sbs.length()-1);
						sb_1.append(sb1);
						sb_1.append(sb2);
						sb_1.append("]}");
						//System.out.println(sb_1.toString());
						//汇总
						sb.append("\"children\": " + sb_1.toString() + "}");
						sb.append("]}");
					}
					else
					{
						//子机构children：
						String sb1 = "{\"Total\":\""+len+"\",\"Rows\":[";
						sbs.append("{ \"name1\": \"0\", \"name2\": \"0\", \"name3\": \"0\", \"name4\": \"0\", \"name5\": \"0\", \"name6\": \"0\", \"name7\": \"0\", \"name8\": \"0\", \"name9\": \"0\", \"name10\": \"0\", \"name11\": \"0\", \"name12\": \"0\", \"name13\": \"0\", \"name14\": \"0\", \"name15\": \"0\", \"name16\": \"0\", \"name17\": \"0\", \"name18\": \"0\", \"name19\": \"0\", \"name20\": \"0\"},");
			
						String sb2 = sbs.substring(0, sbs.length()-1);
						sb_1.append(sb1);
						sb_1.append(sb2);
						sb_1.append("]}");
						if(sb.length()<1)
						{
							sb.append("{\"Total\":\"0\",\"Rows\":[");
							sb.append("{ \"name1\": \"一汽集团\", \"name2\": \"0\", \"name3\": \"0\", \"name4\": \"0\", \"name5\": \"0\", \"name6\": \"0\", \"name7\": \"0\", \"name8\": \"0\", \"name9\": \"0\", \"name10\": \"0\", \"name11\": \"0\", \"name12\": \"0\", \"name13\": \"0\", \"name14\": \"0\", \"name15\": \"0\", \"name16\": \"0\", \"name17\": \"0\", \"name18\": \"0\", \"name19\": \"0\", \"name20\": \"0\",");
						}
						//汇总
						sb.append("\"children\": " + sb_1.toString() + "}");
						sb.append("]}");
					}
					//System.out.println(sb.toString());
				}else{
					sb.append("{\"Total\":\"0\",\"Rows\":[");
					sb.append("{ \"name1\": \"一汽集团\", \"name2\": \"0\", \"name3\": \"0\", \"name4\": \"0\", \"name5\": \"0\", \"name6\": \"0\", \"name7\": \"0\", \"name8\": \"0\", \"name9\": \"0\", \"name10\": \"0\", \"name11\": \"0\", \"name12\": \"0\", \"name13\": \"0\", \"name14\": \"0\", \"name15\": \"0\", \"name16\": \"0\", \"name17\": \"0\", \"name18\": \"0\", \"name19\": \"0\", \"name20\": \"0\",");
			        sb.append("\"children\":{\"Total\":\"0\",\"Rows\":[");
			        sb.append("{ \"name1\": \"\", \"name2\": \"352\", \"name3\": \"300\", \"name4\": \"52\", \"name5\": \"21\", \"name6\": \"21\", \"name7\": \"21\", \"name8\": \"21\", \"name9\": \"21\", \"name10\": \"21\", \"name11\": \"21\", \"name12\": \"21\", \"name13\": \"21\", \"name14\": \"21\", \"name15\": \"21\", \"name16\": \"21\", \"name17\": \"21\", \"name18\": \"21\", \"name19\": \"21\", \"name20\": \"21\", \"name21\": \"21\", \"name22\": \"21\", \"name23\": \"21\", \"name24\": \"21\", \"name25\": \"21\", \"name26\": \"21\", \"name27\": \"21\", \"name28\": \"100.00\", \"name29\": \"21\", \"name30\": \"21\", \"name31\": \"21\"}");
			        sb.append("]}}");
					sb.append("]}");
				}	  
			}else{
				sb.append("{\"Total\":\"0\",\"Rows\":[");
				sb.append("{ \"name1\": \"一汽集团\", \"name2\": \"0\", \"name3\": \"0\", \"name4\": \"0\", \"name5\": \"0\", \"name6\": \"0\", \"name7\": \"0\", \"name8\": \"0\", \"name9\": \"0\", \"name10\": \"0\", \"name11\": \"0\", \"name12\": \"0\", \"name13\": \"0\", \"name14\": \"0\", \"name15\": \"0\", \"name16\": \"0\", \"name17\": \"0\", \"name18\": \"0\", \"name19\": \"0\", \"name20\": \"0\",");
		        sb.append("\"children\":{\"Total\":\"0\",\"Rows\":[");
		        sb.append("{ \"name1\": \"\", \"name2\": \"352\", \"name3\": \"300\", \"name4\": \"52\", \"name5\": \"21\", \"name6\": \"21\", \"name7\": \"21\", \"name8\": \"21\", \"name9\": \"21\", \"name10\": \"21\", \"name11\": \"21\", \"name12\": \"21\", \"name13\": \"21\", \"name14\": \"21\", \"name15\": \"21\", \"name16\": \"21\", \"name17\": \"21\", \"name18\": \"21\", \"name19\": \"21\", \"name20\": \"21\", \"name21\": \"21\", \"name22\": \"21\", \"name23\": \"21\", \"name24\": \"21\", \"name25\": \"21\", \"name26\": \"21\", \"name27\": \"21\", \"name28\": \"100.00\", \"name29\": \"21\", \"name30\": \"21\", \"name31\": \"21\"}");
		        sb.append("]}}");
				sb.append("]}");
			}
//		StringBuffer sb_11=new StringBuffer();
//        sb_11.append("{\"Total\":\"0\",\"Rows\":[");
//		sb_11.append("{ \"name1\": \"综合室 \", \"name2\": \"352\", \"name3\": \"300\", \"name4\": \"52\", \"name5\": \"21\", \"name6\": \"21\", \"name7\": \"21\", \"name8\": \"21\", \"name9\": \"21\", \"name10\": \"21\", \"name11\": \"21\", \"name12\": \"21\", \"name13\": \"21\", \"name14\": \"21\", \"name15\": \"21\", \"name16\": \"21\", \"name17\": \"21\", \"name18\": \"21\", \"name19\": \"21\", \"name20\": \"21\", \"name21\": \"21\", \"name22\": \"21\", \"name23\": \"21\", \"name24\": \"21\", \"name25\": \"21\", \"name26\": \"21\", \"name27\": \"21\", \"name28\": \"100.00\", \"name29\": \"21\", \"name30\": \"21\", \"name31\": \"21\"}");
//		sb_11.append("]}");
//		StringBuffer s=new StringBuffer();
//        s.append("{\"Total\":\"1\",\"Rows\":[");
//        s.append("{ \"name1\": \"社会事业部\", \"name2\": \"12352\", \"name3\": \"9473\", \"name4\": \"2879\", \"name5\": \"21\", \"name6\": \"21\", \"name7\": \"21\", \"name8\": \"21\", \"name9\": \"21\", \"name10\": \"21\", \"name11\": \"21\", \"name12\": \"21\", \"name13\": \"21\", \"name14\": \"21\", \"name15\": \"21\", \"name16\": \"21\", \"name17\": \"21\", \"name18\": \"21\", \"name19\": \"21\", \"name20\": \"21\", \"name21\": \"21\", \"name22\": \"21\", \"name23\": \"21\", \"name24\": \"21\", \"name25\": \"21\", \"name26\": \"21\", \"name27\": \"21\", \"name28\": \"100.00\", \"name29\": \"21\", \"name30\": \"21\", \"name31\": \"21\", \"children\": " + sb_11.toString() + "}");
//		s.append("]}");
	//System.out.println(sb.toString());
		return sb.toString();

	}

	@Override
	public Object insert(Object jsonArray) throws Exception {
		return null;
	}

	@Override
	public Object update(Object jsonArray) throws Exception {
		return null;
	}

	@Override
	public Object delete(Object jsonArray) throws Exception {
		return null;
	}

	/**
	 * 描述：expData 人员导出
	 * 
	 * @param jsonArray
	 * @return
	 * @throws Exception
	 * @CreateOn
	 * @author wangli
	 */
	public Object download(Object jsonArray) throws Exception {
		UserBean user = (UserBean) this.getRequest().getSession().getAttribute("userBean");
		JSONArray array = JSONArray.fromObject(jsonArray);
		JSONObject jsonObject = JSONObject.fromObject(array.getString(0));
		String url = this.getRequest().getSession().getServletContext().getRealPath("/jsp/app/xls/");
		String model = url + "/model/sygl_tongji.xls";
		String file = url + "/file/sygl_tongji.xls";
		String rfile = "jsp/app/xls/file/sygl_tongji.xls";
		File ffrom = new File(model);
		File fto = new File(file);
		Common.copyFile(ffrom, fto);
		List<Object[]> listtotal = new ArrayList<Object[]>();
		String[] subOrg;
		String strOrg="";
		String orgIds = jsonObject.getString("orgIds");//机构ID串
		if(StringUtils.isNotBlank(orgIds)){
			subOrg = user.getCurSubOrgIds(orgIds).split(",");
		}else{
			subOrg = user.getCurSubOrgId().split(",");
		}
		strOrg = user.getCurSubOrgIds(orgIds);//获取当前某一机构及以下的总数
		if(subOrg.length>0)
		{
			int len=0;
			for(int m=0;m<subOrg.length;m++)
			{
				//查询当前组织机构的名称
				//System.out.println("组织机构："+subOrg[m]);
				String empSql = "select CAPTION from t_department where DEPARTMENT_ID ="+subOrg[m]+"";
				List<Object> lemp = AccessDataBaseUtil.query4List(empSql,null);
				if(lemp.size()>0)
				{
					StringBuffer buff = new StringBuffer();
					//查出已婚育龄夫妻双方，生育情况人数
					buff.append(" FROM(SELECT f.org_id,p.tbepr_option as id,n.tbenm_plan_status as status1,f.tbfi_id as tbe_name,n.tbenm_gravida_num as status2,n.reserve4 as types")
							.append(" from tbe_pregnancy_record p LEFT JOIN tbe_neonate_main n ON p.tbepr_id=n.tbepr_id")
							.append(" LEFT JOIN tb_family_base f ON p.tbfi_id=f.tbfi_id where (n.reserve5 is NULL or n.reserve5 <> '1')")
							.append(" UNION ")
					//已婚育龄男1.无妻子：离异，丧偶 2.有妻子：妻子年龄20-49
							.append(" SELECT e.org_id,e.tbe_id as id,e.tbe_sex as status1,tbe_name,'total' as status2,'birth' as types FROM tb_employee e LEFT JOIN tb_family_base f ON e.tbe_id=f.tbe_id where ")
							.append("(tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or f.tbfi_spouse_birthday is null")
							.append(" or (f.tbfi_spouse_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and f.tbfi_spouse_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR)))")
							.append(" and tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
							.append(" and e.tbe_employment_forms <> '31' and e.tbe_sex='男' ")
							.append(" UNION ")
						//已婚育龄女//年龄20-49
							.append(" SELECT org_id,tbe_id as id,tbe_sex as status1,tbe_name,'total' as status2,'birth' as types FROM tb_employee where ")
							.append(" tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
							.append(" and tbe_employment_forms <> '31' and tbe_sex='女' and tbe_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and tbe_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR)")
							.append(" UNION ")
						//已婚育龄无生育男【离异，丧偶，不孕症】妻子年龄20-49
							.append(" SELECT e.org_id,e.tbe_id as id,e.tbe_sex as status1,tbe_name,'no' as status2,'birth' as types FROM tb_employee e LEFT JOIN tb_family_base f ON e.tbe_id=f.tbe_id where")
							.append(" (tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or (((f.tbfi_spouse_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and f.tbfi_spouse_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR)) or f.tbfi_spouse_birthday is null) and tbe_is_barrenness='1'))")
							.append(" and tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
							.append(" and e.tbe_employment_forms <> '31' and e.tbe_sex='男' ")
						//已婚育龄无生育女
							.append(" UNION ")
							.append(" SELECT org_id,tbe_id as id,tbe_sex as status1,tbe_name,'no' as status2,'birth' as types FROM tb_employee where tbe_id not in (SELECT tbe_id from tb_employee where tbe_is_barrenness='0' and the_is_menopause='0'")
							.append(" and tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617')) and tbe_birthday <= DATE_SUB(curdate(),INTERVAL 20 YEAR) and tbe_birthday >= DATE_SUB(curdate(),INTERVAL 49 YEAR) ")
							.append(" and tbe_marital_status not in ('8A90F0D0176C4961B322BEB26703A320') and tbe_status not in('102-5','102-4','102-3')")
							.append(" and tbe_employment_forms <> '31' and tbe_sex='女' ")
						//死亡，已离职，已退休状态,未婚状态的除外
							.append(" UNION ")
					//办证[劳务用工和已离职和已退休的员工不能添加]
							.append("SELECT e.org_id,o.tbeocr_id as id,e.tbe_id as status1,f.tbe_spouse_id as tbe_name,o.reserve2 as status2,'credent' as types")
							.append(" from tb_family_base f LEFT JOIN tb_employee e on f.tbe_id=e.tbe_id LEFT JOIN tbe_only_child_record o on f.tbfi_id=o.tbfi_id where e.tbe_employment_forms <> '31' and f.tbfi_children_num = 1 and tbe_status not in('102-4','102-3') and e.tbe_sex='男'")
							.append(" UNION ")
							.append("SELECT e.org_id,o.tbeocr_id as id,f.tbe_spouse_id as status1,e.tbe_id as tbe_name,o.reserve2 as status2,'credent' as types")
							.append(" from tb_family_base f LEFT JOIN tb_employee e on f.tbe_id=e.tbe_id LEFT JOIN tbe_only_child_record o on f.tbfi_id=o.tbfi_id where e.tbe_employment_forms <> '31' and f.tbfi_children_num = 1 and tbe_status not in('102-4','102-3') and e.tbe_sex='女')t where 1 = 1 ");
					len++;
					String name = lemp.get(0).toString();

					if(m>0)
					{
						buff.append(" and org_id in (" + subOrg[m] + ") ");//单个分支机构
					}
					else
					{
						buff.append(" and org_id in (" + strOrg + ") ");//汇总机构
					}
					
					String querySql = "SELECT org_id,id,status1,tbe_name,status2,types" + buff.toString();
					String[] fields = {"org_id", "id","status1","tbe_name","status2", "types"};
					//System.out.println("querySql:"+querySql);
					List<Map<String, String>> list = AccessDataBaseUtil.query(fields, querySql,null);
					
					int pregnancying = 0;//等孕
					int pregnancyed = 0;//怀孕
					int plan = 0;//婴儿数
					int plan1 = 0;//计划一
					int plan2 = 0;//计划二
					int late = 0;//晚婚+晚育
					
					//生育
					int pregnancy=0;//已婚育龄总职工数
					int pregnancym=0;//已婚育龄男
					int pregnancyf=0;//已婚育龄女
					int nobirthp=0;//无生育职工
					int nobirthm=0;//无生育男
					int nobirthf=0;//无生育女
					
					//办证情况
					int	child= 0;//子女数
					int emp = 0;//应办证
					int credentied = 0;//已办证
					int credentials=0;//未办证
					List<Map<String, String>> listchild = new ArrayList<Map<String, String>>();
					if (list.size() > 0) {
						//pregnancy = list.size();
						for (int i = 0; i < list.size(); i++) {// 行
							Map<String, String> map = list.get(i);
							if(map.get("types").equals("credent"))//办证
							{
								Map<String, String> mapfm = new HashMap<String, String>();
								mapfm.put(map.get("status1"),map.get("status2"));
								//子女数
								if(!listchild.contains(mapfm))
								{
									listchild.add(mapfm);
								}
								
								//已办证
								if (!map.get("id").equals("")) {
									if(map.get("status2").equals(""))
									{
										credentied += 1;
									}
								}
								emp++;
							}
							else if(map.get("types").equals("birth"))
							{
								if(map.get("status2").equals("no"))
								{
									if(map.get("status1").equals("男"))
									{
										nobirthm += 1;
									}else{nobirthf += 1;}
								}else{
									if(map.get("status1").equals("男"))
									{
										pregnancym += 1;
									}else{pregnancyf += 1;}
								}
							}else{
								if (map.get("id").equals("0")) {
									pregnancyed += 1;//怀孕
								}
								if (map.get("id").equals("1")) {
									pregnancying += 1;//等孕
								}
								if (map.get("status1").equals("0")) {//计划内一胎
									String num = map.get("status2");// 胎数
									num = num.equals("") ? "0" : num;
									plan1 += Integer.parseInt(num);
									plan += Integer.parseInt(num);
									
									if (map.get("types").equals("1")) {//晚婚+晚育
										late += Integer.parseInt(num);
									}
								}
								if (map.get("status1").equals("1")) {//计划内二胎
									String num = map.get("status2");// 胎数
									num = num.equals("") ? "0" : num;
									plan2 += Integer.parseInt(num);
									plan += Integer.parseInt(num);
								}
							}
						}
					}
					child = listchild.size();
					credentials = emp - credentied;
					
					nobirthp = nobirthm + nobirthf;
					pregnancy = pregnancym + pregnancyf;
					int havebirth = (pregnancy > nobirthp) ? pregnancy-nobirthp : 0;//有生育职工
					int havebirthm=(pregnancym > nobirthm) ? pregnancym-nobirthm : 0;//有生育男
					int havebirthf=(pregnancyf > nobirthf) ? pregnancyf-nobirthf : 0;//有生育女
					
					if(m>0)
					{
						String[] arr = {name,String.valueOf(pregnancy),String.valueOf(pregnancym),String.valueOf(pregnancyf),String.valueOf(nobirthp),String.valueOf(nobirthm),String.valueOf(nobirthf),String.valueOf(havebirth),String.valueOf(havebirthm),String.valueOf(havebirthf),String.valueOf(emp),String.valueOf(credentied),String.valueOf(credentials),String.valueOf(child),String.valueOf(pregnancyed),String.valueOf(pregnancying),String.valueOf(plan),String.valueOf(plan1),String.valueOf(plan2),String.valueOf(late)};
						listtotal.add(arr);
					}
					else
					{
						String[] arr = {name,String.valueOf(pregnancy),String.valueOf(pregnancym),String.valueOf(pregnancyf),String.valueOf(nobirthp),String.valueOf(nobirthm),String.valueOf(nobirthf),String.valueOf(havebirth),String.valueOf(havebirthm),String.valueOf(havebirthf),String.valueOf(emp),String.valueOf(credentied),String.valueOf(credentials),String.valueOf(child),String.valueOf(pregnancyed),String.valueOf(pregnancying),String.valueOf(plan),String.valueOf(plan1),String.valueOf(plan2),String.valueOf(late)};
						listtotal.add(arr);
					}
				}
			}
		}else{
			String[] arr = {"一汽集团","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"};
			listtotal.add(arr);
		}

		String date = FormatUtil.getCurentDate();

//		List<Object[]> listtotals = new ArrayList<Object[]>();
//		String[] arr = {"铸造厂","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21"};
//		listtotals.add(arr);
		if(listtotal.size() > 0){
			POIFSFileSystem filein = new POIFSFileSystem(new FileInputStream(fto));
			HSSFWorkbook book = new HSSFWorkbook(filein);
			HSSFSheet sheet = book.getSheet("生育情况统计表");
			int startRow = 4;
			if(null != listtotal && listtotal.size() > 0){
				HSSFRow row = null;
				row = sheet.createRow(1);
				row.setHeight((short) 500);
				HSSFCell cell1_0 = row.createCell(0);
				HSSFCellStyle cstyle1 = book.createCellStyle();
				cstyle1.setAlignment(CellStyle.ALIGN_RIGHT);
				cstyle1.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
				cell1_0.setCellStyle(cstyle1);
				cell1_0.setCellValue(date);
				
				for (int i = 0; i < listtotal.size(); i++) {
					row = sheet.createRow(i + startRow);
					row.setHeight((short) 400);
					
					//序号
					HSSFCell cell = row.createCell(0);
					cell.setCellValue((i+1) + "");
					
					Object[] metaData = listtotal.get(i);
					for(int j = 0; j < metaData.length; j++) {
						cell = row.createCell(j + 1);
						// 如果不是图片数据，就利用正则表达式判断textValue是否全部由数字组成
						String textValue = metaData[j].toString();
						cell.setCellValue(new HSSFRichTextString(textValue));
					}
				}
			}
			
			FileOutputStream fileOut = new FileOutputStream(file);
			book.write(fileOut);
			fileOut.close();
			
		} else {
			return "{\"result\":false,\"resultmessage\":\"\",\"resultrecord\":\"报表中没有记录\"}";
		}
		
		return "\"" + rfile + "\"";
	}
	
	public Object expData(Object jsonArray) throws Exception {
		Object retList = this.search(jsonArray);
		List<Map<String, String>> list = (List<Map<String, String>>)retList;
		
		List<Object[]> list1 = new ArrayList<Object[]>();
		for(int i = 0; i < list.size(); i++) {
			Map<String, String> map = list.get(i);
			Object[] obj = new Object[20];
			obj[0] = map.get("caption");
			String info = map.get("info");
			String[] infos = info.split("_");
			for(int j = 0; j < infos.length; j++) {
				obj[j + 1] = infos[j];
			}
			list1.add(obj);
		}
		
		String url = this.getRequest().getSession().getServletContext().getRealPath("/jsp/app/xls/");
		String model = url + "/model/sygl_tongji.xls";
		String file = url + "/file/sygl_tongji.xls";
		String rfile = "jsp/app/xls/file/sygl_tongji.xls";
		File ffrom = new File(model);
		File fto = new File(file);
		Common.copyFile(ffrom, fto);
		
		if(list1.size() > 0){
			XLSUtils.writeXls(list1, fto, "生育情况统计表", 5);//写xls内容
		} else {
			return "{\"result\":false,\"resultmessage\":\"\",\"resultrecord\":\"导出结果集没有记录\"}";
		}
		
		return "\"" + rfile + "\"";
	}
	
	public Object search1(Object jsonArray) throws Exception {
		Object retList = this.search(jsonArray);
		
		jsonArray = JSONArray.fromObject(retList);
		String json = jsonArray.toString();
		return json;
	}
	
	public Object search(Object jsonArray) throws Exception {
		UserBean user = (UserBean)this.getRequest().getSession().getAttribute("userBean");
		
		JSONArray array = JSONArray.fromObject(jsonArray);
		JSONObject jsonObject = JSONObject.fromObject(array.getString(0));
		String orgId = jsonObject.getString("orgIds");//机构ID
		
		List<Map<String, String>> list = user.getOrgMap();//所有可见机构ID ids, department_id, caption, levels, child
		List<Map<String, String>> retList = new ArrayList<Map<String, String>>();
		
		StringBuffer buff4 = new StringBuffer();
		List<String> list3 = new ArrayList<String>();
		List<String> list2 = new ArrayList<String>();
		List<String> list1 = new ArrayList<String>();
		
		
		for(Map<String, String> m: list){
			if(m.get("ids").indexOf(orgId) > -1){
				String id = m.get("department_id");
				String levels = m.get("levels");
				String child = m.get("child");
				
				//所有四级、无四级的三级-用group by
				if("3".equals(levels) || ("2".equals(levels) && "0".equals(child))){
					buff4.append("'").append(id).append("',");
				}
				//所有有四级的三级-非group by
				if("2".equals(levels) && !"0".equals(child)){
					list3.add(id +"_"+ user.getSubOrgIds(id));
				}
				if("1".equals(levels)){//二级公司
					list2.add(id +"_"+ user.getSubOrgIds(id));
				}
				if("0".equals(levels)){//一级级公司
					list1.add(id +"_"+ user.getSubOrgIds(id));
				}
			}
		}
		if(buff4.length() > 0) {
			buff4.deleteCharAt(buff4.length() - 1);
		}
		
		StringBuffer buff1 = new StringBuffer();//已婚育龄
		StringBuffer buff2 = new StringBuffer();//已婚育龄
		StringBuffer buff5 = new StringBuffer();//办证
		StringBuffer buff6 = new StringBuffer();//办证
		StringBuffer buff7 = new StringBuffer();//生育
		StringBuffer buff8 = new StringBuffer();//生育
		StringBuffer buff9 = new StringBuffer();//生育
		StringBuffer buff11 = new StringBuffer();//生育
		
		StringBuffer buff12 = new StringBuffer();//怀等孕
		StringBuffer buff13 = new StringBuffer();//怀等孕
		StringBuffer buff14 = new StringBuffer();//计划一胎
		StringBuffer buff15 = new StringBuffer();//计划一胎
		
		//已婚育龄
		String groupSql1 = "select aa.org_id,";
		String groupSql2 = " group by aa.org_id";
		buff1
		.append("count(*) totle,sum(if(aa.tbe_sex ='男',1,0)) man,sum(if(aa.tbe_sex ='女',1,0)) women,")
		.append("sum(if((aa.tbe_is_barrenness = '1' || aa.the_is_menopause = '1' || aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323')),1,0)) cnt1,")
		.append("sum(if(aa.tbe_sex = '男' && (aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') || tbe_is_barrenness = '1'),1,0)) wn,")
		.append("sum(if(aa.tbe_sex = '女' && (aa.tbe_is_barrenness = '1' || aa.the_is_menopause = '1' || aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323')),1,0)) wv,")
		.append("sum(if(aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617') && tbe_is_barrenness <> '1' && aa.the_is_menopause <> '1',1,0))cnt2,")
		.append("sum(if(aa.tbe_sex = '男' && aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617') && tbe_is_barrenness <> '1',1,0)) yn,")
		.append("sum(if(aa.tbe_sex = '女' && aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617') && tbe_is_barrenness <> '1' && aa.the_is_menopause <> '1',1,0)) yv")
		.append(" from (")
		.append("select s.org_id,s.tbe_sex,s.tbe_birthday,s.tbe_marital_status,s.tbe_is_barrenness,s.the_is_menopause,t.tbfi_spouse_birthday")
		.append(" from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4','102-5') and tbe_employment_forms <> '31'")
		.append(" and tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
		.append(" and s.org_id in (");
		
		buff2.append(")")
		.append(") aa")
		.append(" where (aa.tbe_sex = '男' and ((aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or aa.tbfi_spouse_birthday is null)")
		.append(" or (aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617')")
		.append(" and DATE_FORMAT(SYSDATE(),'%Y-%m-%d') BETWEEN DATE_FORMAT(DATE_ADD(aa.tbfi_spouse_birthday,INTERVAL '20' YEAR),'%Y-%m-%d') and DATE_FORMAT(DATE_ADD(aa.tbfi_spouse_birthday,INTERVAL '49' YEAR),'%Y-%m-%d')")
		.append(" ) )) or ( aa.tbe_sex = '女' and aa.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' ")
		.append(" and DATE_FORMAT(SYSDATE(),'%Y-%m-%d') BETWEEN DATE_FORMAT(DATE_ADD(aa.tbe_birthday,INTERVAL '20' YEAR),'%Y-%m-%d') and DATE_FORMAT(DATE_ADD(aa.tbe_birthday,INTERVAL '49' YEAR),'%Y-%m-%d')")
		.append(")")
		.append("");
		
		//应办证
		String sql51 = "select s.org_id,count(*) ";
		String sql52 = "select count(*) ";
		buff5.append(" from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31'")
			.append(" and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and t.tbfi_children_num = 1")
			.append(" and s.org_id in (");
		buff6.append(")");
		String sql53 = " group by s.org_id";

		//已办证
		String sql61 = "select aa.org_id,count(*) ";
		String sql62 = "select count(*) ";
		buff7.append(" from ( select s.org_id,s.reserve1,t.TBFI_ID,s.TBE_ID")
			.append(" from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31' and t.tbfi_children_num = 1 ")
			.append(" and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
			.append(" and s.org_id in (");
		buff8.append(") ) aa, tbe_only_child_record bb where aa.TBFI_ID = bb.TBFI_ID and bb.RESERVE2 <> '1' ");
		String sql63 = " group by aa.org_id";
		
		//双职工数
		String sql71 = "select p.org_id,count(p.TBE_SEX) - count(DISTINCT if(p.TBE_SEX = '男',concat(p.TBE_IDCARD,'_',t.TBFI_SPOUSE_IDCARD),concat(t.TBFI_SPOUSE_IDCARD,'_',p.TBE_IDCARD))) baby";
		String sql72 = "select count(p.TBE_SEX) - count(DISTINCT if(p.TBE_SEX = '男',concat(p.TBE_IDCARD,'_',t.TBFI_SPOUSE_IDCARD),concat(t.TBFI_SPOUSE_IDCARD,'_',p.TBE_IDCARD))) baby";
		
		buff9.append(" from tb_employee p,tb_family_base t where p.TBE_ID = t.TBE_ID ")
			.append(" and t.TBFI_SPOUSE_IDCARD is not null and t.TBFI_SPOUSE_IDCARD <> '' and t.tbfi_children_num = 1 ")
			.append(" and t.ORG_ID in (");
		buff11.append(")");
		String sql73 = " group by p.org_id";
		
		//怀等孕
		String sql81 = "select s.org_id,sum(if(o.tbepr_option='0',1,0)),sum(if(o.tbepr_option='1',1,0))";
		String sql82 = "select sum(if(o.tbepr_option='0',1,0)),sum(if(o.tbepr_option='1',1,0))";
		buff12.append(" from tb_employee s,tb_family_base t,tbe_pregnancy_record o ")
			.append(" where s.tbe_id = t.tbe_id and t.TBFI_ID = o.TBFI_ID and o.tbepr_option in('0','1')")
			.append(" and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31'")
			.append(" and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
			.append(" and s.org_id in (");
		buff13.append(")");
		String sql83 = " group by s.org_id";
		
		//新生儿
		String sql91 = "select s.org_id,sum(p.tbenm_gravida_num),sum(if(p.tbenm_plan_status='0',p.tbenm_gravida_num,0)),sum(if(p.tbenm_plan_status='1',p.tbenm_gravida_num,0)),sum(if(p.reserve4 ='1',p.tbenm_gravida_num,0))";
		String sql92 = "select sum(p.tbenm_gravida_num),sum(if(p.tbenm_plan_status='0',p.tbenm_gravida_num,0)),sum(if(p.tbenm_plan_status='1',p.tbenm_gravida_num,0)),sum(if(p.reserve4 ='1',p.tbenm_gravida_num,0))";
		buff14.append(" from tb_employee s,tb_family_base t,tbe_pregnancy_record o,tbe_neonate_main p")
			.append(" where s.tbe_id = t.tbe_id and t.TBFI_ID = o.TBFI_ID ")
			.append(" and o.tbepr_id = p.tbepr_id and (p.reserve5 is null or p.reserve5 <> '1')")
			.append(" and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31'")
			.append(" and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
			.append(" and s.org_id in (");
		buff15.append(")");
		String sql93 = " group by s.org_id";
		
		String sql = groupSql1 + buff1.toString() + buff4.toString() + buff2.toString() + groupSql2;
		Map<String, String> retMap1 = new HashMap<String,String>();//已婚育龄返回的结果集
		
		String sql5 = sql51 + buff5.toString() + buff4.toString() + buff6.toString() + sql53;
		String sql6 = sql61 + buff7.toString() + buff4.toString() + buff8.toString() + sql63;
		String sql7 = sql71 + buff9.toString() + buff4.toString() + buff11.toString() + sql73;
		Map<String, String> retMap2 = new HashMap<String,String>();//办证返回的结果集
		//初始化办证结果集
		String[] ids1 = buff4.toString().replaceAll("'", "").split(",");
		for(String id: ids1){
			retMap2.put(id, "_aaa_bbb_ccc_ddd");
		}
		
		String sql8 = sql81 + buff12.toString() + buff4.toString() + buff13.toString() + sql83;
		String sql9 = sql91 + buff14.toString() + buff4.toString() + buff15.toString() + sql93;
		
		Map<String, String> retMap3 = new HashMap<String,String>();//生育返回的结果集
		//初始化生育结果集
		for(String id: ids1){
			retMap3.put(id, "_aaa_bbb_ccc_ddd_eee_fff");
		}
		
		List<Object[]>	l1 = AccessDataBaseUtil.query(sql, null);//已婚育龄
		List<Object[]>	l5 = AccessDataBaseUtil.query(sql5, null);//应办证
		List<Object[]>	l6 = AccessDataBaseUtil.query(sql6, null);//已办证
		List<Object[]>	l7 = AccessDataBaseUtil.query(sql7, null);//双职工数
		List<Object[]>	l8 = AccessDataBaseUtil.query(sql8, null);//怀等孕
		List<Object[]>	l9 = AccessDataBaseUtil.query(sql9, null);//生育情况
		
		//四级与无四级的三级
		for(Object[] obj: l1){
			String orgId1 = obj[0].toString();
			String info = obj[1] +"_"+obj[2] +"_"+obj[3] +"_"+obj[4] +"_"+obj[5] +"_"+obj[6] +"_"+obj[7] +"_"+obj[8] +"_"+obj[9];
			retMap1.put(orgId1, info);
		}
		for(Object[] obj: l5){
			String id = obj[0].toString();
			String re = retMap2.get(id);
			retMap2.put(id, re.replaceAll("aaa", obj[1].toString()));
		}
		for(Object[] obj: l6){
			String id = obj[0].toString();
			String re = retMap2.get(id);
			retMap2.put(id, re.replaceAll("bbb", obj[1].toString()));
		}
		for(Object[] obj: l7){
			String id = obj[0].toString();
			String re = retMap2.get(id);
			retMap2.put(id, re.replaceAll("ddd", obj[1].toString()));
		}
		
		for(Object[] obj: l8){
			String id = obj[0].toString();
			String re = retMap3.get(id);
			retMap3.put(id, re.replaceAll("aaa", obj[1].toString()).replaceAll("bbb", obj[2].toString()));
		}
		for(Object[] obj: l9){
			String id = obj[0].toString();
			String re = retMap3.get(id);
			retMap3.put(id, re.replaceAll("ccc", obj[1].toString()).replaceAll("ddd", obj[2].toString()).replaceAll("eee", obj[3].toString()).replaceAll("fff", obj[4].toString()));
		}
		
		//有四级的三级
		for(String ids: list3){
			//已婚育龄
			String[] id = ids.split("_");
			sql = "select " + buff1.toString() + id[1] + buff2.toString();
			List<Object[]>	l2 = AccessDataBaseUtil.query(sql, null);
			Object[] obj = l2.get(0);
			String info = obj[0] +"_"+obj[1] +"_"+obj[2] +"_"+obj[3] +"_"+obj[4] +"_"+obj[5] +"_"+obj[6] +"_"+obj[7] +"_"+obj[8];
			retMap1.put(id[0], info);
			
			retMap2.put(id[0], "_aaa_bbb_ccc_ddd");
			retMap3.put(id[0], "_aaa_bbb_ccc_ddd_eee_fff");
			//应办证
			sql = sql52 + buff5.toString() + id[1] + buff6.toString();
			List<Object> l51 = AccessDataBaseUtil.query4List(sql, null);
			String re = retMap2.get(id[0]).replaceAll("aaa", l51.get(0).toString());
			retMap2.put(id[0], re);
			//已办证
			sql = sql62 + buff7.toString() + id[1] + buff8.toString();
			List<Object> l61 = AccessDataBaseUtil.query4List(sql, null);
			re = retMap2.get(id[0]).replaceAll("bbb", l61.get(0).toString());
			retMap2.put(id[0], re);
			//双职工
			sql = sql72 + buff9.toString() + id[1] + buff11.toString();
			List<Object> l71 = AccessDataBaseUtil.query4List(sql, null);
			re = retMap2.get(id[0]).replaceAll("ddd", l71.get(0).toString());
			retMap2.put(id[0], re);
			
			//怀等孕
			sql = sql82 + buff12.toString() + id[1] +buff13.toString();
			List<Object[]> l81 = AccessDataBaseUtil.query(sql, null);
			Object obj1[] = l81.get(0);
			re = retMap3.get(id[0]).replaceAll("aaa", obj1[0].toString()).replaceAll("bbb", obj1[1].toString());
			retMap3.put(id[0], re);
			
			//怀等孕
			sql = sql92 + buff14.toString() + id[1] +buff15.toString();
			List<Object[]> l91 = AccessDataBaseUtil.query(sql, null);
			Object obj2[] = l91.get(0);
			re = retMap3.get(id[0]).replaceAll("ccc", obj2[0].toString()).replaceAll("ddd", obj2[1].toString()).replaceAll("eee", obj2[2].toString()).replaceAll("fff", obj2[3].toString());
			retMap3.put(id[0], re);
		}
		//二级
		for(String ids: list2){
			String[] id = ids.split("_");
			if(id.length < 2){
				continue;
			}
			sql = "select " + buff1.toString() + id[1] + buff2.toString();
			List<Object[]>	l2 = AccessDataBaseUtil.query(sql, null);
			Object[] obj = l2.get(0);
			String info = obj[0] +"_"+obj[1] +"_"+obj[2] +"_"+obj[3] +"_"+obj[4] +"_"+obj[5] +"_"+obj[6] +"_"+obj[7] +"_"+obj[8];
			retMap1.put(id[0], info);
			
			retMap2.put(id[0], "_aaa_bbb_ccc_ddd");
			retMap3.put(id[0], "_aaa_bbb_ccc_ddd_eee_fff");
			//应办证
			sql = sql52 + buff5.toString() + id[1] + buff6.toString();
			List<Object> l51 = AccessDataBaseUtil.query4List(sql, null);
			String re = retMap2.get(id[0]).replaceAll("aaa", l51.get(0).toString());
			retMap2.put(id[0], re);
			//已办证
			sql = sql62 + buff7.toString() + id[1] + buff8.toString();
			List<Object> l61 = AccessDataBaseUtil.query4List(sql, null);
			re = retMap2.get(id[0]).replaceAll("bbb", l61.get(0).toString());
			retMap2.put(id[0], re);
			//双职工
			sql = sql72 + buff9.toString() + id[1] + buff11.toString();
			List<Object> l71 = AccessDataBaseUtil.query4List(sql, null);
			re = retMap2.get(id[0]).replaceAll("ddd", l71.get(0).toString());
			retMap2.put(id[0], re);
			
			//怀等孕
			sql = sql82 + buff12.toString() + id[1] +buff13.toString();
			List<Object[]> l81 = AccessDataBaseUtil.query(sql, null);
			Object obj1[] = l81.get(0);
			re = retMap3.get(id[0]).replaceAll("aaa", obj1[0].toString()).replaceAll("bbb", obj1[1].toString());
			retMap3.put(id[0], re);
			//怀等孕
			sql = sql92 + buff14.toString() + id[1] +buff15.toString();
			List<Object[]> l91 = AccessDataBaseUtil.query(sql, null);
			Object obj2[] = l91.get(0);
			re = retMap3.get(id[0]).replaceAll("ccc", obj2[0].toString()).replaceAll("ddd", obj2[1].toString()).replaceAll("eee", obj2[2].toString()).replaceAll("fff", obj2[3].toString());
			retMap3.put(id[0], re);
		}
		//一级
		for(String ids: list1){
			String[] id = ids.split("_");
			if(id.length < 2){
				continue;
			}
			sql = "select " + buff1.toString() + id[1] + buff2.toString();
			List<Object[]>	l2 = AccessDataBaseUtil.query(sql, null);
			Object[] obj = l2.get(0);
			String info = obj[0] +"_"+obj[1] +"_"+obj[2] +"_"+obj[3] +"_"+obj[4] +"_"+obj[5] +"_"+obj[6] +"_"+obj[7] +"_"+obj[8];
			retMap1.put(id[0], info);
			
			retMap2.put(id[0], "_aaa_bbb_ccc_ddd");
			retMap3.put(id[0], "_aaa_bbb_ccc_ddd_eee_fff");
			//应办证
			sql = sql52 + buff5.toString() + id[1] + buff6.toString();
			List<Object> l51 = AccessDataBaseUtil.query4List(sql, null);
			String re = retMap2.get(id[0]).replaceAll("aaa", l51.get(0).toString());
			retMap2.put(id[0], re);
			//已办证
			sql = sql62 + buff7.toString() + id[1] + buff8.toString();
			List<Object> l61 = AccessDataBaseUtil.query4List(sql, null);
			re = retMap2.get(id[0]).replaceAll("bbb", l61.get(0).toString());
			retMap2.put(id[0], re);
			//双职工
			sql = sql72 + buff9.toString() + id[1] + buff11.toString();
			List<Object> l71 = AccessDataBaseUtil.query4List(sql, null);
			re = retMap2.get(id[0]).replaceAll("ddd", l71.get(0).toString());
			retMap2.put(id[0], re);
			
			//怀等孕
			sql = sql82 + buff12.toString() + id[1] +buff13.toString();
			List<Object[]> l81 = AccessDataBaseUtil.query(sql, null);
			Object obj1[] = l81.get(0);
			re = retMap3.get(id[0]).replaceAll("aaa", obj1[0].toString()).replaceAll("bbb", obj1[1].toString());
			retMap3.put(id[0], re);
			//怀等孕
			sql = sql92 + buff14.toString() + id[1] +buff15.toString();
			List<Object[]> l91 = AccessDataBaseUtil.query(sql, null);
			Object obj2[] = l91.get(0);
			re = retMap3.get(id[0]).replaceAll("ccc", obj2[0].toString()).replaceAll("ddd", obj2[1].toString()).replaceAll("eee", obj2[2].toString()).replaceAll("fff", obj2[3].toString());
			retMap3.put(id[0], re);
		}
		
		
		String curSubOrgIds = user.getCurSubOrgIds(orgId);
		String[] curSubOrgId = curSubOrgIds.replaceAll("'", "").split(",");
		for(Map<String, String> m: list){
			String id = m.get("department_id");
			for(String id1: curSubOrgId){
				if(id.equals(id1)){
					String t1 = (retMap1.get(id) == null)? "0_0_0_0_0_0_0_0_0" : retMap1.get(id);
					String t2 = (retMap2.get(id) == null)? "_0_0_0_0" : retMap2.get(id).replaceAll("aaa", "0").replaceAll("bbb", "0").replaceAll("ccc", "0").replaceAll("ddd", "0");
					String t3 = (retMap3.get(id) == null)? "_0_0_0_0_0_0" : retMap3.get(id).replaceAll("aaa", "0").replaceAll("bbb", "0").replaceAll("ccc", "0").replaceAll("ddd", "0").replaceAll("eee", "0").replaceAll("fff", "0");
					String t = (t1+t2+t3).replaceAll("__", "_0_").replaceAll("__", "_0_").replaceAll("__", "_0_").replaceAll("__", "_0_");
					if(t.endsWith("_")){
						t += "0";
					}
					Map<String, String> m1 = new HashMap<String, String>();
					m1.put("caption", m.get("caption"));
					m1.put("child", m.get("child"));
					m1.put("child2", m.get("child2"));
					m1.put("id", m.get("department_id"));
					m1.put("info", t);
					retList.add(m1);
				}
			}
		}
		return retList;
	}
	
	/** 
	 * 描述：queryDetail 查看实时统计明细
	 * @param jsonArray
	 * @return
	 * @throws Exception
	 * @CreateOn 2013-1-4  上午09:51:46
	 * @author chun_chang
	 */
	public Object queryDetail(Object jsonArray) throws Exception {
		UserBean user = (UserBean)this.getRequest().getSession().getAttribute("userBean");
		
		JSONArray array = JSONArray.fromObject(jsonArray);
		JSONObject jsonObject = JSONObject.fromObject(array.getString(0));
		String orgId = jsonObject.getString("orgIds");//机构ID
		String type = jsonObject.getString("type");//机构ID
		String child = jsonObject.getString("child");//机构ID
		String subOrgId = "'" + orgId + "'";
		
		if(!"0".equals(child)){
			subOrgId = user.getSubOrgIds(orgId);
		}
		List<Object> list = new ArrayList<Object>();
		
		StringBuffer buff = new StringBuffer();
		StringBuffer buff1 = new StringBuffer();
		StringBuffer buff2 = new StringBuffer();
		
		buff.append("select aa.tbe_id from (")
			.append("select s.tbe_id,s.org_id,s.tbe_sex,s.tbe_birthday,s.tbe_marital_status,s.tbe_is_barrenness,s.the_is_menopause,t.tbfi_spouse_birthday")
			.append(" from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4','102-5') and tbe_employment_forms <> '31'")
			.append(" and tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and s.org_id in ( ")
			.append(subOrgId)
			.append(" ) ) aa")
			.append(" where ( (aa.tbe_sex = '男' and ((aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or aa.tbfi_spouse_birthday is null)")
			.append(" or (aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617')")
			.append(" and DATE_FORMAT(SYSDATE(),'%Y-%m-%d') BETWEEN DATE_FORMAT(DATE_ADD(aa.tbfi_spouse_birthday,INTERVAL '20' YEAR),'%Y-%m-%d') and DATE_FORMAT(DATE_ADD(aa.tbfi_spouse_birthday,INTERVAL '49' YEAR),'%Y-%m-%d')")
			.append(") ))")
			.append(" or ( aa.tbe_sex = '女' and aa.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
			.append(" and  DATE_FORMAT(SYSDATE(),'%Y-%m-%d') BETWEEN DATE_FORMAT(DATE_ADD(aa.tbe_birthday,INTERVAL '20' YEAR),'%Y-%m-%d') and DATE_FORMAT(DATE_ADD(aa.tbe_birthday,INTERVAL '49' YEAR),'%Y-%m-%d')")
			.append("))");
		
		buff1.append(" from tb_employee s,tb_family_base t,tbe_pregnancy_record o ")
			.append(" where s.tbe_id = t.tbe_id and t.TBFI_ID = o.TBFI_ID and o.tbepr_option in('0','1')")
			.append(" and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31'")
			.append(" and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
			.append(" and s.org_id in (");
		
		buff2.append(" from tb_employee s,tb_family_base t,tbe_pregnancy_record o,tbe_neonate_main p")
			.append(" where s.tbe_id = t.tbe_id and t.TBFI_ID = o.TBFI_ID ")
			.append(" and o.tbepr_id = p.tbepr_id and (p.reserve5 is null or p.reserve5 <> '1')")
			.append(" and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31'")
			.append(" and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320'")
			.append("and s.org_id in (");

		
		switch(Integer.valueOf(type)){
			case 3:
				sql = buff.toString();
				break;
			case 4:
				sql = buff.toString() + " and aa.tbe_sex = '男'";
				break;
			case 5:
				sql = buff.toString() + " and aa.tbe_sex = '女'";
				break;
			case 6:
				sql = buff.toString() + " and ( aa.tbe_is_barrenness = '1' or aa.the_is_menopause = '1' or aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323' ))";
				break;
			case 7:
				sql = buff.toString() + " and aa.tbe_sex = '男' and (aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323') or aa.tbe_is_barrenness = '1')";
				break;
			case 8:
				sql = buff.toString() + " and aa.tbe_sex = '女' and (aa.tbe_is_barrenness = '1' or aa.the_is_menopause = '1' or aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A322','8A90F0D0176C4961B322BEB26703A323'))";
				break;
			case 9:
				sql = buff.toString() + " and aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617') and aa.tbe_is_barrenness <> '1' and aa.the_is_menopause <> '1'";
				break;
			case 10:
				sql = buff.toString() + " and aa.tbe_sex = '男' and aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617') and aa.tbe_is_barrenness <> '1'";
				break;
			case 11:
				sql = buff.toString() + " and aa.tbe_sex = '女' and aa.tbe_marital_status in ('8A90F0D0176C4961B322BEB26703A321','EC88549D43494FFE8E277192921D7617') and aa.tbe_is_barrenness <> '1' and aa.the_is_menopause <> '1'";
				break;
			case 12://应办证
				sql = "select s.tbe_id from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and tbe_employment_forms <> '31' and tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and t.tbfi_children_num = 1 and s.org_id in (";
				sql = sql + subOrgId + ")";
				break;
			case 13://已办证
				sql = "select aa.tbe_id from ( select t.TBFI_ID,s.TBE_ID from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31' and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and t.tbfi_children_num = 1 ";
				sql += " and s.org_id in ("+subOrgId + ") ) aa, tbe_only_child_record bb where aa.TBFI_ID = bb.TBFI_ID and bb.RESERVE2 <> '1'";
				break;
			case 14://未办证
				sql = "select aa.tbe_id from ( select t.TBFI_ID,s.TBE_ID from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31' and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and t.tbfi_children_num = 1 ";
				sql += " and s.org_id in ("+subOrgId + ") ) aa, tbe_only_child_record bb where aa.TBFI_ID = bb.TBFI_ID and bb.RESERVE2 <> '1'";
				List<Object> list2 = AccessDataBaseUtil.query4List(sql, null);
				Set<String> set = new HashSet<String>();
				for(Object obj: list2){
					boolean b = set.add(obj.toString());
					if(!b){
						System.out.println(obj.toString());
					}
				}
				
				sql = "select s.tbe_id from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31' and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and t.tbfi_children_num = 1 and s.org_id in (";
				sql = sql + subOrgId + ")";
				List<Object> list1 = AccessDataBaseUtil.query4List(sql, null);
				for(Object obj: list1){
					if(set.add(obj.toString())){
						list.add(obj);
					}
				}
				break;
			case 15://子女数
				sql = "select s.tbe_id from tb_employee s,tb_family_base t where s.tbe_id = t.tbe_id and s.tbe_status not in ('102-3','102-4') and s.tbe_employment_forms <> '31' and s.tbe_marital_status <> '8A90F0D0176C4961B322BEB26703A320' and t.tbfi_children_num = 1 and s.org_id in (";
				sql = sql + subOrgId + ")";
				break;
			case 16://怀孕
				sql = "select s.tbe_id " + buff1.toString() + subOrgId + ") and o.tbepr_option='0'";
				break;
			case 17://等孕
				sql = "select s.tbe_id " + buff1.toString() + subOrgId + ") and o.tbepr_option='1'";
				break;
			case 18://新生儿
				sql = "select s.tbe_id " + buff2.toString() + subOrgId + ") ";
				break;
			case 19://计划内一胎
				sql = "select s.tbe_id " + buff2.toString() + subOrgId + ") and p.tbenm_plan_status='0'";
				break;
			case 20://计划内二胎
				sql = "select s.tbe_id " + buff2.toString() + subOrgId + ") and p.tbenm_plan_status='1'";
				break;
			case 21://晚婚+晚育
				sql = "select s.tbe_id " + buff2.toString() + subOrgId + ") and p.reserve4 ='1'";
				break;
			default: break;
		}
		if(!"14".equals(type)){
			list = AccessDataBaseUtil.query4List(sql, null);
		}
		StringBuffer buff0 = new StringBuffer();
		if(null == list || list.size() == 0){
			return null;
		} else {
			for(Object obj : list) {
				buff0.append("'").append(obj.toString()).append("',");
			}
			buff0.deleteCharAt(buff0.length() - 1);
		}
		
		sql = " from tb_employee s,tb_family_base t where t.TBE_ID = s.TBE_ID and s.TBE_ID in(";
		String countSql = "select count(*)" + sql + buff0.toString() + ")";
		String querySql = "select s.reserve1,s.tbe_name,s.tbe_idcard,s.tbe_sex,s.tbe_birthday,s.tbe_nation,s.tbe_work_permit,s.tbe_employment_forms,s.tbe_marital_status,s.tbe_married_time,s.tbe_marriage_certificate,s.tbe_is_barrenness,s.the_is_menopause,s.tbe_is_late_marriage,s.tbe_is_late_birth,s.tbe_status,s.tbe_birth_control_measures,t.tbfi_spouse_name,t.tbfi_spouse_sex,t.tbfi_spouse_birthday,t.tbfi_spouse_idcard,t.tbfi_spouse_is_join,t.tbfi_children_num,t.tbfi_children_mnum,t.tbfi_children_fnum " + sql + buff0.toString() + ")";
		
		// 排序
		String sortname = this.getRequest().getParameter("sortname");
		String sortorder = this.getRequest().getParameter("sortorder");
		if(StringUtils.isBlank(sortname) || StringUtils.isBlank(sortorder)) {
			querySql += " order by s.tbe_marital_status ";
		} else {
			if("tbfi_spouse_name".equals(sortname) || "tbfi_spouse_sex".equals(sortname) || "tbfi_spouse_birthday".equals(sortname) || "tbfi_spouse_idcard".equals(sortname)
					|| "tbfi_spouse_is_join".equals(sortname) || "tbfi_children_num".equals(sortname) || "tbfi_children_mnum".equals(sortname) || "tbfi_children_fnum".equals(sortname)){
				querySql += " order by t." + sortname + " " + sortorder;
			} else {
				querySql += " order by s." + sortname + " " + sortorder;
			}
		}
		
		String[] fields = {
				"reserve1","tbe_name","tbe_idcard","tbe_sex","tbe_birthday","tbe_nation","tbe_work_permit","tbe_employment_forms",
				"tbe_marital_status","tbe_married_time","tbe_marriage_certificate","tbe_is_barrenness",
				"the_is_menopause","tbe_is_late_marriage","tbe_is_late_birth","tbe_status",
				"tbe_birth_control_measures","tbfi_spouse_name","tbfi_spouse_sex","tbfi_spouse_birthday","tbfi_spouse_idcard",
				"tbfi_spouse_is_join","tbfi_children_num","tbfi_children_mnum","tbfi_children_fnum"
		};
		return AccessDataBaseUtil.query4SQLPagging(fields, countSql, querySql, this.getPage(), this.getPagesize(), null);
	}
	
	
	@Override
	public Object recordCount(Object jsonArray) throws Exception {
		return null;
	}

	@Override
	public Object setRequest(HttpServletRequest request) throws Exception {
		this.request = request;
		return request;
	}

	@Override
	public Object updateBatch(Object jsonArray) throws Exception {
		return null;
	}

	@Override
	public Object onCreate(Object jsonArray) {
		return null;
	}

	@Override
	public Object onDestory(Object jsonArray) {
		return null;
	}

	@Override
	public Object onInit(Object jsonArray) {
		return null;
	}
}